<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\UserGroupXUser
 *
 * @property int $id
 * @property int $user_id 加入拼团的用户
 * @property int $user_group_id 加入的团
 * @property float $pay_amount 支付的价格
 * @property int $status 状态0已加入，1已支付，2已完成，3拼团失败
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\UserGroupXUser onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser wherePayAmount($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser whereUserGroupId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserGroupXUser whereUserId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserGroupXUser withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\UserGroupXUser withoutTrashed()
 * @mixin \Eloquent
 */
class UserGroupXUser extends Model
{
    use SoftDeletes;

    public static function getJoinUser($UGID){
        $data=self::whereUserGroupId($UGID)->whereIn('status',[1,2])->get();
        if (count($data) > 0){
            foreach ($data as $item){
                $item->user_info=UserInfo::getUserInfo($item->user_id);
            }
        }
        return $data;
    }
    public static function getStatusName($status){
        if ($status==0)
            return '待支付';
        if ($status==1)
            return '拼团中';
        if ($status==2)
            return '已完成';
        if ($status==3)
            return '拼团失败';
    }
}
